import axios, { AxiosError } from '../../src/index'

axios({
  method: 'get',
  url: '/simple/get',
  params: {
    type: ['all', 'relative']
  }
})

axios({
  method: 'get',
  url: '/simple/get#hash',
  params: {
    type: 'all'
  }
})

axios({
  method: 'get',
  url: '/simple/get?type=all',
  params: {
    type: 'relative'
  }
})

axios({
  method: 'post',
  url: '/simple/post',
  data: {
    page: 1,
    type: 'all'
  }
}).then(res => {
  console.log(res)
})

axios({
  method: 'post',
  url: '/simple/buffer',
  headers: {
    'content-type': 'application/json;'
  },
  data: new Int32Array([1, 2])
})

axios({
  method: 'post',
  url: '/simple/post',
  responseType: 'json',
  data: {
    page: 1,
    type: 'all'
  }
}).then(res => {
  console.log(res)
})

axios({
  method: 'get',
  url: '/error/timeout',
  timeout: 2000
}).then((res) => {
  console.log(res)
}).catch((e: AxiosError) => {
  console.log(e.message)
  console.log(e.code)
})
